var List = new Class.create();

List.prototype = {
    page:0,
    url:"",
    data:{},
    list:[],
    noMoreData:false,
    cbFunction:undefined,
    initialize:function(){
        this.data["page"] = this.page
    }
    ,getList:function () {
        let _this = this;

        if (_this.noMoreData) {
            alert("没有更多数据了")
            _this.cbFunction(_this.list);
        }else {
            _this.data.page = this.page
            console.log(this.page);
            apiGet(this.url,this.data,function (res) {
                console.log(res);
                if (res.d.length === 0) {
                    alert("没有更多数据了")
                    _this.noMoreData =true
                    _this.cbFunction(_this.list);
                }else {
                    _this.list = _this.list.concat(res.d);
                    _this.cbFunction(_this.list);
                    _this.page++
                }
            });
        }
        return this;
    }
    ,reload:function(){
        this.page = 0;
        this.list = [];
        this.noMoreData = false;
        this.getList();
        return this;
    }

    ,setUrl:function(url){
        this.url = url
        return this;
    }
    ,setData:function(data){
        this.data = data
        this.data.page = this.page
        return this;
    }
    ,setCbFunc:function(func){
        this.cbFunction = func
        return this;
    }

}